<!DOCTYPE html>
<html>

	<head>
		<meta http-equiv="content-type" content="text/html; charset=utf-8" />
		<meta content="telephone=no" name="format-detection" />
		<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1.0,user-scalable=no,viewport-fit=cover" />

		<meta charset="utf-8">
		<script type="text/javascript" src="js/boot.js"></script>
		<title>饭卡充值</title>
	</head>

	<body>
		<div id="page">
			<div class="navbar">
				<img class="navbar-left arrow" src="image/8_2fanhui.png" onclick="javascript:history.back();">
				<div class="nav-title">
				</div>
			</div>
			<div class="content">
				<div class="card-cell van-hairline--bottom">
					工号
					<input class="cell-input" placeholder="请输入员工工号" type="text" v-model="user.workNo" />
				</div>
				<div class="card-cell van-hairline--bottom">
					姓名
					<input class="cell-input" placeholder="请输入员工姓名" type="text" v-model="user.userName" />
				</div>
				<div class="card-cell van-hairline--bottom" style="justify-content: space-between;">
					充值金额
					<input class="rechange-amount" type="number" v-model="user.orderFee" />
				</div>
			</div>
			<a :href="'javascript:app.recharge();'" class="recharge">
				充值
			</a>
		</div>
	</body>

	<script type="text/javascript">
		var openId = localStorage.getItem('openId');
		var app = new Vue({
			el: '#page',
			data: {
				user: {
					workNo: '',
					userName: '',
					openId: openId,
					orderFee: '0.01',
					body: "订单支付",
					ip: '0.0.0.0'
				}
			},
			methods: {
				recharge() {
					var that = this;
					var data = this.user;
					if(data.orderFee > 300) {
						alert("单次充值金额不能大于300元!");
						return;
					}
					var userName = data.userName;
					// alert(JSON.stringify(data));
					http.post("/weixin/account/recharge.do", data, function(page) {
						if(page.success) {
							var data = page.data;
							var order = {
								openId: openId,
								orderFee: data.orderFee,
								body: "饭卡冲值",
								ip: '0.0.0.0',
								orderId: data.orderId,
								userName: userName
							};
							// alert(order.userName);
							http.gotoHtml("/weixin/pay/pay.html", order);
						} else {
							alert(page.message);
						}
					});
				}
			},
			created() {
				var that = this;
				http.get("/user/get.do?openId=" + openId, function(page) {
					if(page.success) {
						var user = page.data;
						// alert(user);
						if(user) {
							common.copyJsObject2(user, that.user);
							that.buttonName = "解除";
						}
					}
				});
			}
		})
	</script>

</html>